package com.ztesoft.ossup.report.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

import com.ztesoft.ossup.report.domain.ReportColumnGroup;

public interface ReportColumnGroupRepo extends JpaRepository<ReportColumnGroup, Long>, JpaSpecificationExecutor<ReportColumnGroup>{
	
	//void updateDataColsByGroupFieldAndReportId(String dataCols, String groupField,Long reportId); 
	
	
	@Query(value = "update report_column_group u set u.data_cols = ?1,u.group_name=?2 where u.group_field = ?3 and u.report_id = ?4", nativeQuery = true)	
	@Modifying
	void updateDataColsByGroupFieldAndReportId(String dataCols,String groupName, String groupField,Long reportId);
	
	List<ReportColumnGroup> findByReportId(Long reportId);
	
	@Query(value = "delete from report_column_group where group_field = ?1 and report_id = ?2", nativeQuery = true)	
	@Modifying
	void deleteByGroupFieldAndReportId( String groupField,Long reportId);
	
	void deleteByReportId(Long reportId);
}
